/*
 * @Author: boyyang
 * @Date: 2022-01-05 14:54:41
 * @LastEditTime: 2022-01-07 10:33:24
 * @LastEditors: boyyang
 * @Description: 
 * @FilePath: \boyyang\src\components\message\index.ts
 */


import { inject } from 'vue'
import { providerKey, IMessageApi } from './messageType'


const useMessage = (): IMessageApi => {
    let api = inject(providerKey, null)
    if (api === null) {
        throw new Error('如果你想使用信息，你需要把调用其方法的组件放在 message-provider 内部并且使用 useMessage 去获取 API。')
    } else {
        return api
    }

}

export {
    useMessage
}


